//本程序演示线程的创建
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <unistd.h>
#include <pthread.h>
void* thmain(void* arg);
int main(int argc,char* argv[])
{
	pthread_t tid=0;
	int ret = pthread_create(&tid, NULL, thmain, NULL);
	if(0!=ret)
	{
		printf("pthread_create failed");
		exit(-1);
	}
	//等待线程退出
	sleep(1);
	printf("before join\n");
	pthread_join(tid,NULL);
	printf("after jion\n");
	return 0;
}
void* thmain(void* arg)
{
	for(int i=0; i<5; ++i)
	{
		sleep(1);
		printf("pthmain sleep(%d) ok\n",i+1);
	}
	return nullptr;
}
